function arrToTree(data) {
    let tree = []
    if (!Array.isArray(data)) {
        return tree
    }
    data.forEach(ele => {
        if (ele.pid === '') return tree.push(nodeObj(ele))
        const obj = getElementById(tree, ele.pid)
        obj && obj.children.push(nodeObj(ele))
    })
    return tree
}
function nodeObj(obj) {
    return {
        id: obj.id,
        label: obj.name,
        children: [],
        job: obj.job
    }
}
function getElementById(arr, id) {
    for(const ele of arr) {
        if(ele.id === id) {
            return ele
        } else if(ele.children.length > 0) {
            const temp = getElementById(ele.children, id)
            if(temp) {
                return temp
            } else {
                continue
            }
        }
    }
}